package cn.secby.orders.domain;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.baomidou.mybatisplus.annotation.*;
import cn.secby.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import cn.secby.common.core.web.domain.BaseEntity;

/**
 * 订单对象 tb_order
 * @author shenkunlin
 * @date 2025-05-06
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "tb_order")
public class Order extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    @TableId(value ="id" ,type = IdType.ASSIGN_ID )
    @JsonSerialize(using=ToStringSerializer.class)
    private Long id;

    /** 订单编号 */
    @Excel(name = "订单编号")
    @TableField(value = "order_no")
    private String orderNo;

    /** 渠道ID */
    @Excel(name = "渠道ID")
    @TableField(value = "channel_id")
    private Long channelId;

    /** 客户ID */
    @Excel(name = "客户ID")
    @TableField(value = "customer_id")
    private Long customerId;

    /** 订单类型 */
    @Excel(name = "订单类型")
    @TableField(value = "order_type")
    private Integer orderType;

    /** 订单总金额 */
    @Excel(name = "订单总金额")
    @TableField(value = "total_amount")
    private Long totalAmount;

    /** 支付状态 */
    @Excel(name = "支付状态")
    @TableField(value = "payment_status")
    private Integer paymentStatus;

    /** 订单状态 */
    @Excel(name = "订单状态")
    @TableField(value = "order_status")
    private Integer orderStatus;

    /** 支付方式 */
    @Excel(name = "支付方式")
    @TableField(value = "payment_method")
    private Integer paymentMethod;

    /** 过期时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "过期时间", width = 40, dateFormat = "yyyy-MM-dd")
    @TableField(value = "expire_time")
    private Date expireTime;

    /** 取消原因 */
    @Excel(name = "取消原因")
    @TableField(value = "cancel_reason")
    private String cancelReason;

    /** 订单来源 */
    @Excel(name = "订单来源")
    @TableField(value = "spu_source")
    private Integer spuSource;

    /** 是否删除  1 未删除  2 已删除 */
    @Excel(name = "是否删除  1 未删除  2 已删除")
    @TableField(value = "is_delete")
    @TableLogic(value = "1", delval = "2")
    private Integer isDelete;

    @TableField(exist = false)
    private List<OrderItem> items;

}
